<extend name="public@base5"/>
<block name="main">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="{:url('admin/App/index')}">{:lang('ADMIN_APP_INDEX')}</a>
            </li>
            <if condition="class_exists('\app\admin\controller\AppStoreController')">
                <li class="nav-item">
                    <a class="nav-link " href="{:url('AppStore/apps')}">{:lang('ADMIN_APPSTORE_APPS')}</a>
                </li>
            </if>
        </ul>
        <form method="post" class="js-ajax-form margin-top-20">
            <php>
                $status=array("1"=>lang('Enabled'),"0"=>lang('Disabled'),"3"=>lang('Not Installed'));
            </php>
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th>{:lang('NAME')}</th>
                    <th>{:lang('Key')}</th>
                    <th>{:lang('Description')}</th>
                    <th>{:lang('Author')}</th>
                    <th>{:lang('Version')}</th>
                    <th width="60">{:lang('STATUS')}</th>
                    <th width="90">{:lang('ACTIONS')}</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="apps" item="vo">
                    <tr>
                        <td>{$vo.title}</td>
                        <td><span class="badge text-bg-info">{$vo.name}</span></td>
                        <td>{$vo.description}</td>
                        <td>{$vo.author}</td>
                        <td><span class="badge text-bg-success">{$vo.version}</span></td>
                        <td>
                            <empty name="vo.installed">
                                <span class="badge text-bg-warning">{:lang('Not Installed')}</span>
                                <else/>
                                <span class="badge text-bg-success">{:lang('Installed')}</span>
                            </empty>
                        </td>
                        <td>
                            <empty name="vo.installed">
                                <a class="btn btn-xs btn-primary js-ajax-dialog-btn"
                                   href="javascript:void(0);"
                                   data-href="admin/apps/{$vo.name}"
                                   data-msg="{:lang('INSTALL_APP_CONFIRM_MSG')}"
                                   title="{:lang('Install')}" data-toggle="tooltip">
                                    <i class="fa fa-plus-circle fa-fw"></i>
                                </a>
                                <else/>
                                <a class="btn btn-xs btn-success js-ajax-dialog-btn"
                                   href="javascript:void(0);"
                                   data-href="admin/apps/{$vo.name}"
                                   data-method="PUT"
                                   data-msg="{:lang('UPDATE_APP_CONFIRM_MSG')}"
                                   title="{:lang('Update')}" data-toggle="tooltip">
                                    <i class="fa fa-refresh fa-fw"></i>
                                </a>
                                <a class="btn btn-xs btn-danger"
                                   href="javascript:doOpenUninstallAppDialog('{$vo.name}')"
                                   data-msg="{:lang('INSTALL_APP_CONFIRM_MSG')}"
                                   title="{:lang('Uninstall')}" data-toggle="tooltip">
                                    <i class="fa fa-trash fa-fw"></i>
                                </a>
                            </empty>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </form>
    </div>
</block>
<block name="scripts">
    <script>
        function doOpenUninstallAppDialog(name) {
            parent.openIframeLayer("{:url('App/uninstall')}?name=" + name, "{:lang('App uninstall')}", {
                area: ['450px', '600px'],
                end: function () {
                    window.location.reload();
                }
            })
        }
    </script>
</block>